04. Three Approaches

Nd113 C5 L02 04 L Three Approaches V1 RENDER V1

Tradeoff Analysis

The following questions compare the three options for storing tickets discussed in the video. For your reference:

Option 1: Prioritized Bags - Three bags of tickets (one each for "high", "medium", and "low" priority). Once a ticket is filled out it is tossed into the appropriate bag.

Option 2: Single box, prioritized first by priority, then by date - One box. High priority tickets go in the back. Low priority go in the front. Within a priority group tickets are sorted by date.

Option 3: Three boxes, one for each priority level - Each box contains tickets of a single priority level, sorted by date.

Let's say you want to find the oldest ticket (of any priority).

On average, which system would take the longest time (slowest lookup) to find the oldest ticket?

SOLUTION: Option 1: Bags of tickets

Narrowing our options

After considering the question above, I decided to rule out option 1. I can't imagine having to scan through every single ticket to find the oldest one.

Whatever system we use, it should have some date-based organization to it.

The following questions weigh the pros and cons of options 2 and 3.

Again, you want to find the oldest ticket of any priority level.

On average, which system would take the shortest time (fastest lookup) to find the oldest ticket?

SOLUTION: Option 3: Three boxes

Regardless of which option you use, once a ticket is filled out it needs to be inserted into a box.

Which option would lead to the fastest inserts of new tickets?

SOLUTION: Option 3: Three boxes

So far we've only been considering the "time" aspects of performance. What about space?

Which of these options would take up the least space in the vehicle?

SOLUTION: Option 2: Single box

Making a choice

After considering the questions above, I decided to go with option 3. It may take up more space in the vehicle, but there's plenty of space in a car and the improved insert and lookup speeds made that an acceptable tradeoff for me.

This sort of thinking is very similar to the tradeoff analysis you do when writing software. Usually there isn't one best-in-every-way solution, but often there is one that is clearly superior for the requirements of the problem.

If you have another solution or just want to discuss these tradeoffs: go to your Student Hub and discuss!